package com.ciwong.epaper.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.util.DeviceUtil;
import com.ciwong.epaper.util.DisplayUtils;

public class DKWorkDialog extends Dialog {
    private View workHintDialogView;
    private String endTime;
    private int x轴的偏移量;
    private int y轴的偏移量;
    private boolean isundowork=false;

    public DKWorkDialog(@NonNull Context context, View workHintDialogView,  String endTime, int x轴的偏移量, int y轴的偏移量, boolean isundowork) {
        super(context,R.style.round_corner_dialog);
        this.workHintDialogView = workHintDialogView;
        this.endTime = endTime;
        this.x轴的偏移量 = x轴的偏移量;
        this.y轴的偏移量 = y轴的偏移量;
        this.isundowork=isundowork;
        init();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }
    private void init() {
        Window window = getWindow();
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.gravity = Gravity.CENTER;
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DeviceUtil.getDeviceWidth(getContext())
                - DisplayUtils.dip2px(getContext(), 16)
                , LinearLayout.LayoutParams.WRAP_CONTENT);


        addContentView(workHintDialogView,params);

        TextView tv_homework_name = (TextView) findViewById(R.id.tv_homework_name);
        TextView tv_homework_end_time = (TextView) findViewById(R.id.tv_homework_end_time);

        TextView tv_homework_tips = (TextView) findViewById(R.id.tv_homework_tips);
        tv_homework_end_time.setText(endTime+"\n");
       /* if(isundowork){

        }else {
            tv_homework_end_time.setVisibility(View.VISIBLE);

        }
        tv_homework_name.setVisibility(View.GONE);
*/
        tv_homework_name.setVisibility(View.GONE);
        tv_homework_tips.setVisibility(View.GONE);
        tv_homework_end_time.setVisibility(View.VISIBLE);
//        attributes.x = x轴的偏移量;
        attributes.y = y轴的偏移量+ DisplayUtils.dip2px(getContext(),7)-DisplayUtils.dip2px(getContext(),6);
        window.setAttributes(attributes);

    }
}
